﻿
#include "buffer.h"
#include <iostream>
#include "tcpserver.h"

void ConnectHandler(const ConnectionPtr& conn) {
    std::cout << "连接建立" << std::endl;
}

void MessageHandler(const ConnectionPtr &conn, Buffer *buf)
{
    std::cout << "server recv: " << buf->getReadAddr() << std::endl;
    buf->moveReadStep(buf->getReadSize());
    std::string response = "sfwnb";
    conn->send(response.c_str(), response.size());

}

int main()
{
    TcpServer server(58888);
    server.setThreadCount(2);
    server.enableInactiveRelease(10);
    server.setConnectCallback(ConnectHandler);
    server.setMessageCallback(MessageHandler);
    server.start();
    return 0;
}
